package com.candy.control;

import com.candy.service.UserInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.LinkedList;

@WebServlet("/getUserInfoById")
public class GetUserInfoByIdServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        获取前端传递进来的参数
        int userid=Integer.parseInt(req.getParameter("id"));
//       调用业务逻辑处理层
        UserInfoService service=new UserInfoService();
//        获取根据id查询到的用户信息
        LinkedList<LinkedHashMap<String,Object>> userinfoByID= service.getUserInfoById(userid);
//        将数据保存在session中
        req.getSession().setAttribute("userInfoById",userinfoByID);
//        跳转到编辑页面
        req.getRequestDispatcher("updateUserInfo.jsp").forward(req,resp);

    }
}
